package com.neusoft.dto;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;

import javax.validation.constraints.*;
import java.util.Date;
@Data
public class RetroactiveDTO {
    // Getters and Setters
    @NotNull(message = "补签日期不能为空")
    @Past(message = "补签日期必须是过去的日期")
    @JsonFormat(pattern = "yyyy-MM-dd")
    private Date date;

    @NotNull(message = "补签上班时间不能为空")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
    private Date clockInTime;

    @NotNull(message = "补签下班时间不能为空")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
    private Date clockOutTime;

    @NotBlank(message = "补签原因不能为空")
    @Size(max = 200, message = "补签原因不能超过200个字符")
    private String reason;

    // 自定义校验逻辑
    @AssertTrue(message = "补签下班时间必须晚于上班时间")
    private boolean isValidClockTime() {
        return clockOutTime.after(clockInTime);
    }

    public void setDate(Date date) {
        this.date = date;
    }

    public void setClockInTime(Date clockInTime) {
        this.clockInTime = clockInTime;
    }

    public void setClockOutTime(Date clockOutTime) {
        this.clockOutTime = clockOutTime;
    }

    public void setReason(String reason) {
        this.reason = reason;
    }
}
